<?php

// 完善投资人名片
// PUT member.card.complete

namespace app\api\resource\member\card;
use think\Db;
use think\Session;

class Complete
{
    // 方法
    public $_method = ['PUT'];
    // 前置
    public $_pre    = ['login','isTzz'];
    // 描述
    public $_description = '完善投资人名片';
    // 参数
    public $_param  = [
        'uri' => '名片URI',
    ];
    // 返回
    public $_return = [
        201 => '完善成功',
        422 => '名片必须',
        500 => '服务器异常',
    ];

    public function run(&$request)
    {
        $uri = $request->put('uri/s','','trim');

        if ( empty($uri) ) return [422,'名片必须'];

        $memberId = Session::get('member.id');

        $data['card'] = $uri;
        $num = Db::name('member_like')->where('member_id',$memberId)->update($data);

        return ($num >= 0) ? [ 201,[] ] : 500;
    }
}
